<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <h1>Blender file parser.</h1>
        <p>The purpose of this library is to parse the contents of a blend file.</p>
        <p>The project is split in a few packages but from a library user perspective the interest points are
            the BlenderFileParameter and BlenderFile classes in the blenderfile package and the types in
            the elements package. The rest is garbage used by the parser.</p>
        <h1>Concurrency</h1>
        <p>The parsing process is single thread but the parsed contents are (hopefully) safe to
            be used in a multi-thread environment so the result of the blenderFile.getScenes() call
        can be read by as many thread as you please.</p>
        <h1>Getting the data</h1>
        <p>Given the blender file f, open a stream on it:</p>
        {@code File blenderFile = some blend file}<br>
        {@code FileInputStream in = new FileInputStream(blenderFile);}<br>
        <p>Then wrap the stream in a BlenderFileParameters instance:</p>
        {@code BlenderFileParameters param = new BlenderFileParameters(in);}<br>
        <p>With the parameters set, create a BlenderFile instance:</p>
        {@code BlenderFile blenderFile = new BlenderFile(param);}<br>
        <p>Now we can access the file contents. A blender file can contain one or
        more scenes. For each scene, BlenderFile creates a counterpart. We get the
        scenes via the getScenes method of the BlenderFile instance:</p>
        {@code List<BlenderScene> scenes = blenderFile.getScenes();}<br>
        <h2>Example 1, getting the triangles of a mesh</h2>
        <p>Let's say that the file X is a blend file that contains at least one mesh
            in the first layer. To get the positions of the vertices of the triangles in that
            mesh we can write:</p>
        <pre>
            BlenderFileParameters params = new BlenderFileParameters(in);
            BlenderFile blenderFile = new BlenderFile(params);
            List&lt;BlenderScene&gt; scenes = blenderFile.getScenes();
            BlenderScene scene = scenes.get(0);
            BlenderSceneLayer layer = scene.getLayers().get(0);
            List&lt;BlenderObject&gt; meshContainers = layer.getBlenderObjects(ObjectType.MESH);
            BlenderObject firstMeshContainer = meshContainers.get(0);
            BlenderMesh mesh = (BlenderMesh) firstMeshContainer.getObjectData().get(0);
            List&lt;BlenderMeshTriangle&gt; meshTriangles = mesh.getTriangles();
            for (BlenderMeshTriangle t : meshTriangles) {
                BlenderTuple3 v1 = t.getV1().getPosition();
                BlenderTuple3 v2 = t.getV2().getPosition();
                BlenderTuple3 v3 = t.getV3().getPosition();
                ...here's the triangle
            }
        </pre>
    </body>
</html>
